
/*
var ws = new WebSocket(“ws://localhost:8080”);
ws.onopen = function()
{
  console.log(“open”);
  ws.send(“hello”);
};
ws.onmessage = function(evt)
{
  console.log(evt.data)
};
ws.onclose = function(evt)
{
  console.log(“WebSocketClosed!”);
};
ws.onerror = function(evt)
{
  console.log(“WebSocketError!”);
};
*/

var wSocket = {
	create : function(url){
		wSocket.ws = new WebSocket("ws://"+url);
	} , 
	onmessage : function(f){
		ws.onmessage = function(evt){
			f(evt);
		}
	} ,
	onclose : function(f){
		ws.onclose = function(evt){
			f(evt);
		}
	} ,
	onerror : function(f){
		ws.onerror = function(evt){
			f(evt);
		}
	} ,
};


wSocket.create("localhost:8080");

wSocket.onmessage(function(evt){
	alert(evt.data);
});

wSocket.onclose(function(evt){
	alert(evt.data);
});
